-----------------------------------------------------------------------------
--
-- Module      :  LLVM.Code.MiscInfo
-- Copyright   :  Mikhail Belyaev
-- License     :  GPL (Just (Version {versionBranch = [3], versionTags = []}))
--
-- Maintainer  :
-- Stability   :
-- Portability :
--
-- |
--
-----------------------------------------------------------------------------

module LLVM.Code.MiscInfo where

import LLVM.Parser.Record.Record (recordAsList)
import LLVM.Parser.Record.Record (RawRecord(..))

import LLVM.Util

acVersion :: RawRecord -> Maybe Integer
acVersion rr = case recordAsList rr of
                    (_:1:v:_) -> Just v
                    otherwize -> Nothing

acStringInfo :: Integer -> RawRecord -> Maybe String
acStringInfo code rr = case recordAsList rr of
                            (_:cd:str) | cd == code -> Just $ massOrd str
                            otherwise -> Nothing

acCodeModuleTriple :: RawRecord -> Maybe String
acCodeModuleTriple = acStringInfo 2
acDataLayout :: RawRecord -> Maybe String
acDataLayout = acStringInfo 3
acModuleAsm :: RawRecord -> Maybe String
acModuleAsm = acStringInfo 4
acCodeSection :: RawRecord -> Maybe String
acCodeSection = acStringInfo 5
acDepLib :: RawRecord -> Maybe String
acDepLib = acStringInfo 6
acGCName :: RawRecord -> Maybe String
acGCName = acStringInfo 11

